// Utility to bind to a datapump that returns a dictionary whose values
// might be datapumps.
//
// Copyright 2006 (C) Ralph Thomas

#ifndef MISSION_DATAPUMPS_DICTIONARY_HELPER_H
#define MISSION_DATAPUMPS_DICTIONARY_HELPER_H

#include <adobe/value.hpp>
#include <adobe/dictionary.hpp>
#include <adobe/adam.hpp>
#include <boost/function.hpp>
#include <binder.hpp>
#include <vector>

namespace datapumps {
	struct dictionary_helper_t
	{
		typedef boost::function<void (const adobe::dictionary_t&)> monitor_t;

		dictionary_helper_t(adobe::sheet_t& sheet);
		~dictionary_helper_t();
		void initialize(const adobe::value_t& value, const monitor_t& monitor);
		void substitute(const adobe::name_t& name, const adobe::value_t& value);

		typedef std::vector<adobe::binder_helper_t*> helper_list_t;
	  private:
		adobe::sheet_t&			sheet_m;
		adobe::binder_helper_t	bind_m;
		adobe::dictionary_t		dict_m;
		helper_list_t			helpers_m;
		monitor_t				monitor_m;
		bool					init_m;
	};
}

#endif

